package cc.mango.android.chartview;

import static cc.mango.android.chartutil.ChartCommons.SUNFLOWER_ROTATE_ANGLE_STEP;
import static cc.mango.android.chartutil.ChartCommons.UP_CHART_BACKGROUND_COLOR;
import static cc.mango.android.chartutil.ChartCommons.UP_CHART_TOP_REGINE_COLOR;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;

public class UpSunFlowerView extends BaseView
{

	public UpSunFlowerView(Context context, Bitmap bm)
	{
		super(context, bm);
		// TODO Auto-generated constructor stub

	}

	@Override
	public void onDraw(Canvas canvas)
	{
		// TODO Auto-generated method stub
		super.onDraw(canvas);

		//		canvas.drawColor(SUNFLOWER_TRASPARENT_BACKGROUND_COLOR);
		canvas.setDrawFilter(pfd); //modified by haibo, 2011-06-13, 图片抗锯齿效果
		if (isShowBackground)
		{

			canvas.drawColor(Color.BLACK);

			paint.setColor(UP_CHART_BACKGROUND_COLOR);

			canvas.drawRect(leftWidth, topHeight, width - rightWidth, height
					- bottomHeight, paint);

			paint.setColor(UP_CHART_TOP_REGINE_COLOR);

			//			canvas.drawRect(leftWidth, topHeight, width - rightWidth, 0, paint);	//SDK2.2以后无法绘制，左上角顶点和右下角顶点不能交换

			canvas.drawRect(width - rightWidth, 0, leftWidth, topHeight,
					paint);
		}

		canvas.rotate(angle, x, y);

		canvas.drawBitmap(bm, x - bmWidth / 2, y - bmHeight / 2, null);

		angle = (angle + SUNFLOWER_ROTATE_ANGLE_STEP) % 360;

	}

	public void initSize(int width, int height)
	{

		leftWidth = width / 10;
		rightWidth = width / 25;
		topHeight = height / 8;
		bottomHeight = height / 8;
	}
}